package jh.com.jhappbf.ui;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import jh.com.jhappbf.R;
import jh.com.jhappbf.fragmentactivity.MyFragmentActivity;

/**
 * @author Administrator
 */
public class MainUI extends Activity implements OnClickListener {

    private Button mBtnAssayQuery;
    private Button mBtnPwdUpdate;
    private Button mBtnAppQuit;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main_ui_activity);
        initView();
    }

    /**
     * @summary: 初始化
     */
    private void initView() {
        mBtnAssayQuery = findViewById(R.id.main_assay_query);
        mBtnPwdUpdate = findViewById(R.id.main_update_pwd);
        mBtnAppQuit = findViewById(R.id.main_app_quit);
        mBtnAssayQuery.setOnClickListener(this);
        mBtnPwdUpdate.setOnClickListener(this);
        mBtnAppQuit.setOnClickListener(this);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.login, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_assay_query:
                openAssay();
                break;
            case R.id.menu_pwd_update:
                openUpdatePwd();
                break;
            case R.id.menu_app_quit:
                this.finish();
                break;
            default:
                break;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.main_assay_query:
                openAssay();
                break;
            case R.id.main_update_pwd:
                openUpdatePwd();
                break;
            case R.id.main_app_quit:
                this.finish();
                break;
            default:
                break;
        }
    }

    /**
     * 进入查询界面
     */
    private void openAssay() {
        Intent intent = new Intent(MainUI.this, MyFragmentActivity.class);
        intent.putExtra("flag", "assay");
        startActivity(intent);
    }

    /**
     * 进入修改密码界面
     */
    private void openUpdatePwd() {
        Intent intent = new Intent(MainUI.this, UpdatePwd.class);
        startActivity(intent);
    }


}
